using System;
using TireService.Data;
using System.Collections.Generic;
using System.Linq;
namespace TireService.Web.Reports.Design
{
    partial class ServiceCarSchedules
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        public ServiceCarSchedules(DateTime ScheduleDate, int ContainerId)
        {
            this.InitializeComponent();

            // Bind data to report
            TireServiceDB db = new TireServiceDB();

            List<ServiceCarSchedulePackingView> serviceschedules = db.ServiceCarSchedulePackingViews.Where(p => p.ContainerId == ContainerId & p.ScheduleDate == ScheduleDate).ToList();

            var schedules = from p in serviceschedules
                            group p by new { p.ServiceCarId } into yg
                            select new
                            {
                                ServiceCarId = yg.Key.ServiceCarId
                            };

            foreach (var schedule in schedules)
            {
                // Add more documents in the end if more than one schedule
                ServiceCarSchedule schedulereport = new ServiceCarSchedule(schedule.ServiceCarId, ScheduleDate);
                schedulereport.CreateDocument();
                this.Pages.AddRange(schedulereport.Pages);

                //// Add summary page in end of report
                //ServiceCarScheduleDayOverview scheduleoverview = new ServiceCarScheduleDayOverview(schedule.ServiceCarId, ScheduleDate);
                //scheduleoverview.CreateDocument();
                //this.Pages.AddRange(scheduleoverview.Pages);
            }

            db.Dispose();
        }

        public ServiceCarSchedules(DateTime ScheduleDate, int ServiceCarId, bool Show)
        {
            this.InitializeComponent();

            // Bind data to report
            TireServiceDB db = new TireServiceDB();

            // Add more documents in the end if more than one schedule
            ServiceCarSchedule schedulereport = new ServiceCarSchedule(ServiceCarId, ScheduleDate);
            schedulereport.CreateDocument();
            this.Pages.AddRange(schedulereport.Pages);

            // Add summary page in end of report
            ServiceCarScheduleDayOverview scheduleoverview = new ServiceCarScheduleDayOverview(ServiceCarId, ScheduleDate);
            scheduleoverview.CreateDocument();
            this.Pages.AddRange(scheduleoverview.Pages);            

            db.Dispose();
        } 

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Detail = new DevExpress.XtraReports.UI.DetailBand();
            this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
            this.BottomMargin = new DevExpress.XtraReports.UI.BottomMarginBand();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            // 
            // Detail
            // 
            this.Detail.Name = "Detail";
            this.Detail.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // TopMargin
            // 
            this.TopMargin.Name = "TopMargin";
            this.TopMargin.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.TopMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // BottomMargin
            // 
            this.BottomMargin.Name = "BottomMargin";
            this.BottomMargin.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.BottomMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // ServiceCarSchedules
            // 
            this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
            this.Detail,
            this.TopMargin,
            this.BottomMargin});
            this.Landscape = true;
            this.PageHeight = 827;
            this.PageWidth = 1169;
            this.PaperKind = System.Drawing.Printing.PaperKind.A4;
            this.Version = "10.2";
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();

        }

        #endregion

        private DevExpress.XtraReports.UI.DetailBand Detail;
        private DevExpress.XtraReports.UI.TopMarginBand TopMargin;
        private DevExpress.XtraReports.UI.BottomMarginBand BottomMargin;
    }
}
